import ajax from './index'

export interface GetProductsParam {
  name?: string
  coding?: string
}

export interface Products {
  id: number,
  name: string,
  coding: string,
  purchasing_price: string,
  selling_price?: string,
  created_at?: string,
}

export function getProducts (param: GetProductsParam): Promise<Products[]> {
  return ajax('/getProducts', param, 'post')
}

export function removeProduct (id: number) {
  return ajax('/removeProduct', { id }, 'post')
}

export function createdProduct (param: Products) {
  return ajax('/createdProduct', param, 'post')
}

export function setProduct (param: Products) {
  return ajax('/setProduct', param, 'post')
}
